﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace MixingStation
{
    public class PCIHelper
    {
        public static string RedGreenValue(long value)
        {
            string res = "";

            for (int i = 0; i < 8; i++)
            {
                int x = int.Parse(Math.Pow(2, i).ToString());
                long re = value & x;
                if (re == 0)
                {
                    res += "0";
                }
                else
                {
                    res += "1";
                }

            }


            return res;
        }

    }
    public class PCIControl//pci红绿灯控制
    {


        /*    
         * function long SmedDllInit() library "SmedDll.dll"
           function long SmedDllExit() library "SmedDll.dll"
           function long UpdateLED1(int bit,boolean mode) library "SmedDll.dll" 
            function long Getfeatures() library "SmedDll.dll"
           function long CheckDi() library "SmedDll.dll"
           subroutine InitDll(long Thandle) library "SmedDll.dll"
            subroutine FreeDLL() library "smeddll.dll"
           * */

        [DllImport("SmedDll.dll")]//初始化
        public static extern long SmedDllInit();

        [DllImport("SmedDll.dll")]//退出
        public static extern long SmedDllExit();


        [DllImport("SmedDll.dll")]//pci开关
        public static extern long UpdateLED1(int bit, bool mode);

        [DllImport("SmedDll.dll")]//检查红外状态
        public static extern long CheckDi();

        [DllImport("SmedDll.dll")]//获取红绿灯状态
        public static extern long Getfeatures();
    }
}
